<?php 
	require_once ("../../config.php");
?>
<html>
<head>
<title>ITControl Masisa</title>
<link rel="stylesheet" href="/itcontrol/com/visual/style.css">
</head>
	<body>
		<div id="div_navbar" align="right">
			<?php 	
				# Add div with Navbar
				echo navbar();
			?>
		</div>
		<div id="div_menu" align="left">
			<?php 		
				# Include div with Menu			
				echo menu();
			?>
		</div>
		<div id="div_form" align="left">
			<form id="form_main" name="form_main" method="post" action="unit_edit_db.php">
				<?php
				 
					# Get id and city value from the selected item
					$id = $_GET["action"];
					
					# Explode values into an array
					$values = explode("-", $id);
					
					# Mount array with fields from Unit
					$fields[0] = "id";
					$fields[1] = "nameUnit";
					$fields[2] = "cnpj";
					
					# Mount array with alias from Unit
					$namefields[0] = "ID";
					$namefields[1] = "Unidade";
					$namefields[2] = "CNPJ";
					
					# Create where to values
					$where[0] = "id = '" .$values[0] . "'";
					
					$tableOpt[0] = "tb_uf";
					
					$typeOpt[0] = "uf";
					
					# Mount array with fields from UF
					$fieldsOpt[0] = "city";
					
					# Mount array with alias from UF
					$namefieldsOpt[0] = "Cidade";
					
					# Selected value on OptionButton
					$on[0] = $values[1];

					echo loadDataOpt("tb_unit", "unit", "edit", $fields, $namefields, $tableOpt, $typeOpt, "edit", $fieldsOpt, $namefieldsOpt, $where, $on);
					echo menuaction("unit", "edit");
				?>
			</form>
		</div>
	</body>
</html>
